package com.zhongkai.model3;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.codehaus.jackson.annotate.JsonBackReference;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Collection;
import java.util.Objects;

@Entity
@Table(name = "set_role",    catalog = "")
public class SetRole implements Serializable {
    private Integer id;
    private String name;
    private String remove;
    private Collection<MenusRole> menusRolesById;

    @Id
    @Column(name = "id")
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "remove")
    public String getRemove() {
        return remove;
    }

    public void setRemove(String remove) {
        this.remove = remove;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SetRole setRole = (SetRole) o;
        return Objects.equals(id, setRole.id) &&
                Objects.equals(name, setRole.name);
    }

    @Override
    public int hashCode() {

        return Objects.hash(id, name);
    }

    @JsonBackReference
    @JsonIgnore
    @OneToMany(mappedBy = "setRoleById")
    public Collection<MenusRole> getMenusRolesById() {
        return menusRolesById;
    }

    public void setMenusRolesById(Collection<MenusRole> menusRolesById) {
        this.menusRolesById = menusRolesById;
    }
}
